package com.ruoyi.controller;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.service.HouseService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 物理房型管理
 * 2024-10-24
 */
@RestController
@RequestMapping("/hotel/house")
public class HouseController extends BaseController {

    @Autowired
    HouseService houseService;

    @GetMapping("/getHouseList")
    public AjaxResult getHouseList(@RequestParam Map map) {
        // 本地的酒店ID
        List<String> columnDateRange = StringUtils.getListStringByMap(map, "columnDateRange");
        String hotelId = map.get("hotelId").toString();
        return success(houseService.getHouseList(hotelId, columnDateRange));
    }

    /**
     * 添加艺龙标准库
     *
     * @param map
     * @return
     */
    @GetMapping("/getElongHouseList")
    public AjaxResult getElongHouseList(@RequestParam Map map) {
        // 本地的酒店ID
        String hotelId = map.get("hotelId").toString();
        return success(houseService.getElongHouseList(hotelId));
    }

    /**
     * 添加房型
     *
     * @param map
     * @return
     */
    @PostMapping("/postAddElongHouse")
    public AjaxResult postAddElongHouse(@RequestBody Map map) {
        return houseService.postAddElongHouse(map);
    }

    /**
     * 修改房型维度的数据
     *
     * @param jsonObject
     * @return
     */
    @PostMapping("/postUpdateHouseDimension")
    public AjaxResult postUpdateHouseDimension(@RequestBody JSONObject jsonObject) {
        return toAjax(houseService.postUpdateHouseDimension(jsonObject));
    }

    /**
     * 批量开关房
     *
     * @param jsonObject
     * @return
     */
    @PostMapping("/postBatchSwitchRoom")
    public AjaxResult postBatchSwitchRoom(@RequestBody JSONObject jsonObject) {
        return houseService.postBatchSwitchRoom(jsonObject);
    }

    /**
     * 房型下线
     *
     * @param jsonObject
     * @return
     */
    @PostMapping("/postShelvesHouse")
    public AjaxResult postShelvesHouse(@RequestBody JSONObject jsonObject) {
        return houseService.postShelvesHouse(jsonObject);
    }

    /**
     * 更新房型名称
     *
     * @return
     */
    @PostMapping("/postUpdateRoomName")
    public AjaxResult postUpdateRoomName(@RequestBody JSONObject jsonObject) {
        return houseService.postUpdateRoomName(jsonObject);
    }
}
